package it.salvatore.parser;
/**
 * 
 */


import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Attribute;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 * @author Elio
 *
 */
public class TestLogin {

	public Document get(String URL) throws IOException{
		Document doc = Jsoup.connect(URL).get();
		return doc;		
	}
	public Document post(String URL) throws IOException{
		Document doc = Jsoup.connect(URL).post();
		return doc;		
	}
	
	public void login (String username,String password,RemoteServiceClientListener callback){
		ExecutorService executor = Executors.newSingleThreadExecutor();
		LoginTask task = new LoginTask(username, password, callback);
		executor.execute(task);
	}
	
	public static void main (String args[]){
		TestLogin dummy = new TestLogin();
		RemoteServiceClientListener RemoteServiceClientListener = new RemoteServiceClientListener() {
			
			@Override
			public void loginPerformed(String jsessionid) {
				System.out.println("login performed "+ jsessionid);
				
			}
			
			@Override
			public void loginFailed(int errorCode) {
				System.out.println("login failed");
				
			}
			
			@Override
			public void loginFailed(Throwable error) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void searchPerformed(ArrayList result) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void searchFailed(Throwable error) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void searchFailed(int errorCode) {
				// TODO Auto-generated method stub
				
			}
		};
		dummy.login("user", "pw", RemoteServiceClientListener);
		
		
			
		
		}


}
